Micron Document
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| SparkN0de-git | SparkN0de |
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Commit b05bf1bb17d25237fd1ce1d54e2aaf9536d0c506


Parents : 4ba8812
Author : Ivan <ivan@quad4.io>
Signature : Signature validation error
Date : 2026-04-23T02:30:45-05:00

feat(audio): fix Codec2MicrophoneRecorder with silent tap for audio processing and ensure audio context resumes correctly

Changes

1 files changed, 21 insertions(+), 0 deletions(-)


Diff

diff --git a/meshchatx/src/frontend/public/assets/js/codec2-emscripten/codec2-microphone-recorder.js b/meshchatx/src/frontend/public/assets/js/codec2-emscripten/codec2-microphone-recorder.js
index 5760a5cc..163773ba 100644
--- a/meshchatx/src/frontend/public/assets/js/codec2-emscripten/codec2-microphone-recorder.js
+++ b/meshchatx/src/frontend/public/assets/js/codec2-emscripten/codec2-microphone-recorder.js
@@ -33,6 +33,18 @@ class Codec2MicrophoneRecorder {
// send mic audio to audio worklet
this.mediaStreamSource = this.audioContext.createMediaStreamSource(this.microphoneMediaStream);
this.mediaStreamSource.connect(this.audioWorkletNode);
+ this._silentTap = this.audioContext.createGain();
+ this._silentTap.gain.value = 0;
+ this.audioWorkletNode.connect(this._silentTap);
+ this._silentTap.connect(this.audioContext.destination);
+
+ if (typeof this.audioContext.resume === "function") {
+ try {
+ await this.audioContext.resume();
+ } catch {
+ // ignore
+ }
+ }
// successfully started recording
return true;
@@ -58,6 +70,15 @@ class Codec2MicrophoneRecorder {
this.audioWorkletNode.disconnect();
}
+ if (this._silentTap) {
+ try {
+ this._silentTap.disconnect();
+ } catch {
+ // ignore
+ }
+ this._silentTap = null;
+ }
+
// close audio context
if (this.audioContext && this.audioContext.state !== "closed") {
this.audioContext.close();


──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────